package xuliehualiu;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;

public class demo4 {
    public static void main(String[] args) throws IOException {
          /*
            利用转换流按照指定字符编码写出
        */
        //jdk11以后的
        FileReader fr=new FileReader("gbkfile.txt", Charset.forName("GBK"));
        FileWriter fw=new FileWriter("b.txt",Charset.forName("UTF-8"));
        int len;
        while ((len=fr.read())!=-1){

               fw.write(len);
        }
        fw.close();
        fr.close();
    }
}
